# Better output readability
def puts what
  super what.to_s + "\n-----\n"
end

puts 1 + 1

puts "1" + "1"

puts 2 + 2 * 5

puts (2 + 2) * 5

puts "Ahoj" + "Sáro"

puts "Ahoj" + " " + "Sáro"

begin
  puts "Ahoj" + 2
rescue TypeError => chyba
  puts "CHYBA! Číslo není totéž co písmeno! (Ruby said: #{chyba})"
end

puts [1, 2, 3].to_s

puts [1, 2, 3].to_s * 2

puts [1, 2, 3].to_s.to_i * 2

puts "Nebudu ve škole zlobit\n" * 10

200.times do
  puts "Nebudu ve škole zlobit. "
end

1.upto 200 do |i|
  print "#{i}. Nebudu ve škole zlobit. "
end
print "\n-----\n"

# http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Array/Conversions.html#M000378
class Array
  def to_sentence  
    case length
      when 0
        ""
      when 1
        self[0]
      when 2
        "#{self[0]} a #{self[1]}"
      else
        "#{self[0...-1].join(', ')} a #{self[-1]}"
    end
  end
end

puts [1, 2, 3].to_sentence

puts ['Hynek', 'Vilém', 'Jarmila'].to_sentence